import service from "../utils/request";
import { LoginType } from "../types";

// 注册接口
export const registerModule = () => service.post({ url: "/auth/register" });

export const getLogin = (data: LoginType) =>
  service.post({
    url: "/authweb/oauth2/token",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    auth: {
      // 由后端定义好提供
      username: "egrant-web",
      password: "secret",
    },
    data: data,
  });

/**
 * 切换角色接口
 * @param data 角色id
 * @returns
 */
export const changeRoles = (data: { roleId: number }) =>
  service.post({ url: "/authweb/oauth2/role-select", params: data });

/**
 * 退出登录接口
 * @returns
 */
export const loginout = () => {
  return service.get({ url: "/authweb/oauth2/logout" });
};
// 获取个人信息
export const getUserInfo = () => {
  return service.get({ url: "/userweb/mvc/index/personByPsn" });
};
